#include <bits/stdc++.h>
//#include "head.h"

using namespace std;
using ll = long long;

void solve()
{
    ll n;
    cin >> n;
    vector<pair<ll, ll>> v(3e5 + 5);
    for (int i = 1; i <= n; i++)
    {
        cin >> v[i].first;
        v[i].first += i - 1;
        v[i].second = i;
    }
    sort(v.begin() + 1, v.begin() + n + 1);
    set<ll> st;
    st.emplace(n);
    for (int i = 1; i <= n; i++)
        if (st.count(v[i].first))
            st.emplace(v[i].first + v[i].second - 1);
    cout << *st.rbegin() << endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}